package com.hw8.utils;

import com.ehw8.base.domain.pojo.Result;

import java.text.MessageFormat;

/**
 * @author <a href='mailto:acttosma@outlook.com'>Acttos Ma</a>
 * @date 2020-01-02 22:46
 */
public enum ErrorEnum {
    SUCCESS(0, ""),
    /**
     * 错误枚举
     */
    USER_STATUS_ERROE(-1, "账号异常，请联系客服！"),
    NOT_WORKING_TIME(-2, "每天 8:00 ~ 23:00 为交易时间！"),
    NOT_COIN_BOX_OPEN_TIME(-2, "每天 08:00 ~ 20:00 为开放时间！"),
    AUTHENTICATION_ERROR(-3, "您还未完成实名认证！"),
    PROHIBITED_TRADING_DUE_TO_REGISTRATION_24(-4, "注册时间小于24小时，没有交易权限！"),
    TRADE_PWD_ERROR(-5, "交易密码错误"),
    TODAY_TRADE_NOT_FINISHED(-6, "您今天还有订单未完成，请先完成当前订单再交易！"),
    SELLING_TOP_LIMIT(-7, "出售次数受限，每日只可进行三次卖单！"),
    TOO_MANY_BUY(-71, "今日购买次数达到100次上限！"),
    TOO_MANY_SELL(-71, "今日出售次数达到100次上限！"),
    FREQUENCY_LIMIT_BUY(-71, "发布买单频繁，请在{0}后发布"),
    FREQUENCY_LIMIT_SELL(-71, "发布卖单频繁，请在{0}后发布"),
    FREQUENCY_LIMIT_SELL_AFTER_BUY(-71, "【安全升级】\n购买成功后24小时内不可出售\n请在{0}后再试"),
    @Deprecated
    SEQUENCE_ERROR(-8, "获取id失败!"),//该值停用，不应该返回给用户如此粒度的信息
    GEM_NOT_SUFFICIENT(-9, "账户钻石不足"),
    GB_NOT_SUFFICIENT(-9, "账户GB不足"),
    COIN_NOT_SUFFICIENT(-9, "账户{0}余额不足"),
    PAYMENT_COIN_NOT_SUFFICIENT(-9, "{0}余额不足"),
    TRADE_FAILED(-10, "交易失败"),
    TRADE_FROZEN_GEM_LESS(-10, "冻结钻石数量异常，交易失败！"),
    PAID_FAILED(-11, "付款失败"),
    PAID_COIN_FAILED(-12, "放币失败"),
    FEATURE_HAS_BEEN_PAUSED(-12, "很抱歉！该功能临时关闭，请稍后再试！"),
    @Deprecated
    CREATE_SELL_PAUSED(-12, "很抱歉！该功能临时关闭，请稍后再试！"),
    UPDATE_USER_GEM_FAILED(-13, "更新用户钻石失败"),
    ADD_REP_FAILED(-14, "更新荣誉值流水失败"),
    VERIFY_FAILED(-15, "您的登录状态已失效，请您重新登录"),
    USER_NOT_EXIST(-16, "用户不存在"),
    CITY_NOT_EXIST(-16, "您选择的城市不存在"),
    CITY_CONFIRMED(-16, "您已经确认过竞选城市:{0}"),
    CITY_NOT_CONFIRMED(-16, "您还没有确认竞选城市"),
    LOCATION_NOT_FOUND(-16, "您的所在城市没有数据，请联系客服更新位置信息"),
    INVITEE_NOT_ENOUGH(-16, "新增实名人数不足，无法申请"),
    NEED_APPLY_FOR_CITY_PARTNER(-16, "您还没有申请第二城主，请先申请"),
    INVITER_NOT_EXIST(-16, "邀请人信息不正确"),
    PASSWORD_WRONG(-17, "密码错误"),
    TEAM_NO_MEMBERS(-39, "您的团队目前没有人员加入"),
    @Deprecated
    USER_BALANCE_NOT_ENOUGH(-18, "用户余额不足"),
    MINNINGS_ENOUGH(-19, "超过该类型矿机可兑换数量上限"),
    MINNING_TIMEOUT(-20, "矿机超时，无法续费"),
    MINNING_NOT_EXIST(-20, "该类型矿机不存在或已下架"),
    MINING_RENEW_DAILY_LIMIT(-20, "该矿机当天续费次数达到上限，无法续费"),
    TRADE_MAX_ERROE(-21, "超过最大买卖数量限制(单笔不超{0}枚)"),
    TRADE_MIN_ERROE(-21, "低于最小买卖数量限制(单笔不低于{0}枚)"),
    COIN_BOX_MAX_ERROE(-21, "超过最大转入数量限制(单笔不超{0}{1})"),
    COIN_BOX_MIN_ERROE(-21, "低于最小转入数量限制(单笔不低于{0}{1})"),
    COIN_BOX_AMOUNT_STEP_ERROE(-21, "转入数量必须是{0}的整数倍"),
    TRADE_BAN(-22, "交易封禁"),
    FAKE_MINNING_ID(-23, "矿机类型id值非法"),
    FAKE_USER_ID(-24, "用户id值非法"),
    MINNING_RENEW_FAIL(-25, "续费矿机失败，请稍后再试"),
    MINNING_EXCHANGE_FAIL(-25, "兑换矿机失败，请稍后再试"),
    MINNING_EXCHANGE_UPDATE_GEM_FAIL(-26, "用户兑换矿机，更新钻石数量失败"),
    LOCATION_ALL_CITY_FAKE_TYPE(-27, "type参数非法"),
    LOCATION_EMPTY_CITY_LIST(-28, "城市列表为空"),
    REQUESTED_DATA_EMPTY(-29, "您请求的数据为空"),
    USER_HAS_BEEN_PROHIBITED(-30, "您的账户已被封禁，请联系客服"),
    PROHIBITED_FOR_DOING_(-30, "您的账户已被禁止{0}\n请提交工单或联系客服"),
    GEM_AMOUNT_IS_NOT_LEGAL(-31, "钻石数量应为正整数"),
    GB_AMOUNT_IS_NOT_LEGAL(-31, "GB数量应为正整数"),
    COIN_BOX_AMOUNT_IS_NOT_INTEGER(-31, "转入数量应为正整数"),
    COIN_AMOUNT_IS_NOT_LEGAL(-31, "交易数量应为正整数"),
    TRADE_PWD_NEED_TO_MODIFY(-32, "请到\"我的\"界面右上角齿轮图标修改交易密码"),
    GEM_PRICE_IS_NOT_IN_SYS_ZONE(-33, "您的价格不在平台价格区间内"),
    PROHIBITED_SELLING_DUE_TO_AUTHENTIFICATION_48(-34, "您的账号还在交易锁定期\n实名后48小时内暂不能出售{0}"),
    TRADE_PWD_DANGER_NEED_TO_MODIFY(-35, "您的交易密码安全系数较低\n请到\"我的\"界面右上角齿轮图标修改交易密码"),
    IDENTIFICATION_ID_ILLEGAL(-36, "请输入正确的身份证号码"),
    IDENTIFICATION_ID_CHECK_FAIL(-36, "身份证号码校验失败"),
    IDENTIFICATION_ID_FRONT_NEEDED(-36, "请上传身份证人像面图片"),
    IDENTIFICATION_ID_BACK_NEEDED(-36, "请上传身份证国徽面图片"),
    TRADE_PWD_REMAINS_THE_SAME(-37, "交易密码不能和最近使用的密码相同"),
    TRADE_PWD_WITHOUT_SALT(-38, "账号安全系统全面升级\n请到\"我的\"界面右上角齿轮图标修改交易密码"),
    TRADE_SELLER_IP_LIMIT(-38, "检测到您的账户存在异常\n交易功能已暂停，次日恢复正常"),

    //    SYSTEM_ERROR(10000, "系统异常，请稍后再试"),
    SYSTEM_ERROR(10000, ""),
    SYSTEM_MAINTAINING(10000, "系统维护中，欢迎稍后再试"),
    LOGIN_FAILD(10001, "登录失败"),
    PWDERROR(10003, "密码错误"),
    SMS_SEND_FAIL(10004, "短信发送失败"),
    VALIDATE_CODE_ERROR(10005, "验证码错误或已失效，请重新获取"),
    USER_EXIST(10006, "用户已存在"),
    INVITER_CODE_NOT_EXIST(10007, "邀请码不存在"),
    PARAMETER_ERROR(10008, "参数错误"),
    USER_NOT_LOGIN(10009, "用户未登录"),
    ORDER_NOT_EXIST(100010, "订单不存在或已取消"),
    CANCEL_FAIL_DUE_TO_GRABBED(100011, "您的订单已被抢定，取消失败"),
    CANCEL_FAIL(100011, "取消失败"),
    CREATE_COMMENT_FAIL(100012, "发表评论失败"),
    TOPICS_NOT_EXIST(100013, "该话题不存在"),
    GOLD_FLOW_CREATE_FAIL(100014, "创建贡献值流水失败"),
    IDNUM_EXIST(100015, "该身份证已存在"),
    AMOUNT_MIN_ERROR(100016, "最低提现金额20元！"),
    AMOUNT_ERROR(100017, "金额错误！"),
    WITHDRAW_ERROR(100018, "有未完成提现订单"),
    COMMENT_NOT_EXIST(100019, "该评论不存在"),
    NO_SUPPORT_CONTACT_AVAILABLE(100020, "当前客服全忙，请您稍后再试"),
    LOGIN_DEVICE_ID_DISMATCH(100021, "账号已绑定其他设备，请解绑设备"),
    LOGIN_DEVICE_ID_BINDED(100022, "设备已绑定其他账号，请解绑设备"),
    AUTHENTICATION_FAIL(100023, "实名认证失败"),
    LOGIN_STATUS_ILLEGAL(100024, "登录状态异常，请联系客服"),
    ALIPAY_EXIST(100025, "您输入的支付宝账号已存在"),
    ALIPAY_ERROR(100026, "请输入正确的支付宝账号"),
    TRADE_PAY_TYPE_NOT_SUPPORTED(100026, "该订单不支持当前支付方式，请稍后再试"),
    REP_NOT_ENOUGH(100027, "荣誉值不足，交易失败"),
    EXCEED_MAX_CHANGE_DEVICE(100028, "本年度解绑次数已耗尽"),
    ALREADY_UNBIND(100029, "处于允许解绑状态中,不能再次解绑"),
    FAILED_TO_UNBIND(100030, "设备解绑失败"),

    SMS_SEND_DAILY_FREQUENTLY(100031, "今日发送短信数量已达到最高限额"),
    ORDER_HAS_BEEN_ORDERED(100032, "该订单已被他人抢单，下次快点哦"),
    ORDER_GRABBED_EXISTS(100032, "请完成当前抢到的订单\n抢单后1分钟内无法匹配新的订单"),
    ORDER_STATUS_NOT_EQUAL_PAID(100033, "订单尚未完成支付"),
    ORDER_STATUS_CANCELED(100033, "该订单已取消"),
    ORDER_STATUS_CREATED(100033, "订单已创建"),
    ORDER_STATUS_WAITING_FOR_SELLER(100033, "订单等待匹配卖家"),
    ORDER_STATUS_PAID(100033, "订单已完成支付"),
    ORDER_STATUS_COMPLETED(100033, "订单交易已完成"),
    ORDER_STATUS_COMPLETED_BY_YOURSELF(100033, "您已完成交易，请勿重复提交"),
    ORDER_STATUS_COMPLETED_BY_OTHERS(100033, "订单交易已完成"),
    ORDER_STATUS_APPEALED(100033, "订单已提交申诉"),
    ORDER_STATUS_CAN_NOT_APPEAL(100033, "订单不满足申诉条件"),
    ORDER_CANCEL_FAILED(100034, "订单取消失败，请稍后再试"),
    CONCURRENT_CONTROL_LIMITED(100035, "请求处理中，请耐心等候"),
    MOBILE_NUMBER_ILLEGAL(100036, "请输入正确的手机号码\n手机号码请勿以数字0开头"),
    SOURCE_NOT(100037, "获取来源异常，请重试"),
    OLD_PWD_ERROR(100038, "原密码错误"),
    INVITER_CODE_ALREADY_EXIST(100039, "邀请码已存在"),
    INVITER_CODE_ERROR(100040, "邀请码为2-8位的字母或数字"),
    PARAMETER_VALUE_ERROR(100041, "参数值错误"),
    PICTURE_ALREADY_EXISTS(100041, "上传图片重复"),
    TRADE_48_HOURS_SELL_ERROR(100042, "购买钻石后48小时以内不允许出售"),
    TRADE_PWD_FORMAT_ERROR(100043, "交易密码必须为8-20位数字+字母组合"),
    FAILED_TO_MODIFY_PWD(100044, "登录密码修改失败"),
    SMS_SEND_MINUTELY_FREQUENTLY(100045, "发送过于频繁，请1分钟后再试"),
    FACE_VERIFY_FAIL(100046, "人脸识别验证失败"),
    TRUE_NAME_ERROR(100047, "请输入真实姓名(与所填身份证对应)"),
    ID_NUM_ERROR(100048, "身份证号不存在"),
    FACE_VERIFY_HIGH_RISK(100049, "刷脸失败次数过多，请您稍后再试"),
    FAILED_TO_MODIFY_TRADE_PWD(100050, "交易密码修改失败"),
    OPERATION_TOO_FREQUENTLY(100051, "您的操作过于频繁，请稍后再试"),
    AUTHENTICATION_UNFINISHED_ORDER_ERROR(100052, "已支付，请耐心等候"),
    PASSCODE_NOT_MATCH(1000533, "好友口令错误"),
    SYSTEM_BUSY(100053, ""),//系统繁忙，请稍后再试

    FLASH_MOBILE_ERROR(100053, "获取手机号码失败"),
    DATABASE_ERROR(100054, "数据操作失败"),
    DATABASE_NOTEXIST(100055, "尚无相关数据"),
    COS_ERROR(100056, "cos错误"),
    PAY_ERROR(100057, "请输入正确的收款账号"),
    PAY_EXIST(100058, "您输入的收款账号已存在"),
    DEFAULT_ACCOUNT_ERROR(100059, "默认收款账号不能删除"),
    MAN_MACHINE_VERIFY_FAIL(100060, "人机验证失败，请稍后再试"),
    WORK_ORDER_ERROR(10061, "当前用户拥有一个未处理的工单"),

    NEED_DOUBLE_CHECK(10062, "需要二次验证"),                                  //此处code禁止修改
    NOT_NEED_DOUBLE_CHECK(10063, "不需要二次验证"),                            //此处code禁止修改
    DOUBLE_CHECK_SUCCESS(10064, "二次验证成功"),                               //此处code禁止修改
    DOUBLE_CHECK_FAIL(10065, "二次验证失败"),
    WORK_ORDER_NUMBER_ERROR(10066, "您今天提交工单太过频繁，请明天再试"),
    ILLEGAL_NICKNAME(10066, "昵称包含敏感词汇，请修改昵称"),
    ORDER_CANNOT_CANCEL(100067, "当前订单无法取消"),
    WORK_ORDER_ERROR_REVIEW(100068, "当前工单已经评价"),
    ERROR_EXCHANGE_GEM_NUM(100069, "兑换钻石必须大于0"),
    ERROR_EXCHANGE_USER_CONDITION(100070, "主账户不符合兑换规则"),
    ADD_EXCHANGE_GEM_FAILED(100071, "添加兑换钻石流水失败"),
    ADD_GEM_FAILED(100072, "添加钻石流水失败"),
    GEM_EXCHANGE_NUM_MUST_INTEGER(100073, "钻石必须是整数"),
    EXCHANGE_FAIL_MININGS_NOT_MATCH(100074, "您持有的矿机未满足兑换条件"),
    GEM_EXCHANGE_SWITCH_CLOSE(100075, "钻石兑换功能已关闭"),
    GEM_LESS_THAN_FIXED_NOT_SUFFICIENT(100076, "您兑换的钻石数低于兑换最低标准！"),
    GEM_EXCHANGE_GB_SWITCH_CLOSE(100077, "钻石兑换GB功能已关闭"),
    GEM_EXCHANGE_STOCK_SWITCH_CLOSE(100078, "钻石兑换股权功能已关闭"),
    GEM_EXCHANGE_STOCK_MAIL_NUM_ERROR(100079, "无可邮寄股权证书"),
    GEM_EXCHANGE_STOCK_UNPAID_MAIL_ERROR(100080, "您有一笔未支付的邮寄订单"),
    DOUBLE_CHECK_FAIL_AND_SUBMIT_INFO(100081, "二次验证失败,请完善二次验证信息"),
    DOUBLE_CHECK_INFO_NOT_EXIST(100082, "未查到二次验证信息"),
    DOUBLE_CHECK_INFO_SUBMIT_ERROR(100083, "提交二次验证信息失败 "),
    GEM_EXCHANGE_STOCK_PAID_MAIL_ERROR(100084, "当前邮寄订单已支付"),
    REPEATED_SUBMISSION_PLEASE_NOT(100085, "请勿重复点击"),

    CHECK_GEM_PROCESSED(100086, "当前补钻已处理"),

    IM_GAME_ERROR(20000, "游戏id异常"),
    IM_GAME_KEY_ERROR(20001, "用户主键或游戏主键为空，请联系客服"),
    IM_GAME_GROUP_TITLE_NULL(20002, "群名称不能为空"),
    IM_GAME_GROUP_TITLE_REPEAT(20003, "群名称已存在"),
    IM_GROUP_MEMBERS_NOT(20004, "用户未加入群"),
    IM_GROUP_NOT(20005, "群不存在"),
    IM_GROUP_OWNER_EXIT(20006, "由于您是群主，请将群主转让与群内其他成员"),
    IM_GROUP_NOT_PERMISSION(20007, "您无权限操作"),
    IM_GROUP_MANAGE_MAX_NUM(20008, "群内管理员数量已达上限"),
    IM_GROUP_MEMBERS_JOIN(20009, "用户已加入群"),
    IM_ADD_GROUP_ERROR(21000, "添加群聊表失败"),
    IM_ADD_GROUP_INFOS_ERROR(21001, "添加群基础信息表失败"),
    IM_ADD_GROUP_MEMBERS_ERROR(21002, "添加群成员表失败"),
    IM_GAME_NOT_GROUP_ERROR(21003, "当前游戏未设置群聊"),
    GAME_NOTDISCOUNT(21004, "该游戏不可使用钻石抵扣"),
    IM_FORBIDDEN_ADD(21005, "你已违反该群规则，禁止加入该群"),

    /**
     * 新手指南异常
     */
    App_Guides_NOT_ERROR(30000, "该视频不存在，或已被删除"),
    //评论相关
    COMMENT_NOT_FONT_ERROR(40000, "评论不存在或已被删除"),
    COMMENT_LIKE_ERROR(40001, "您已经点过赞啦"),
    COMMENT_DISLIKE_ERROR(40002, "您已经踩过啦"),
    //COMMENT_ONLY_LIKE_ERROR(40003,"一条评论只能点赞或者踩共计一次"),

    CONCURRENT_CONTROL_PAID_COIN(8001, "频繁操作，请勿重复提交"),              //此处code禁止修改
    CONFIRM_ALERT_INFO(9000, "{0}"),                                       //此处code禁止修改
    USERINFO_NOT_EXIST(50000, "没有对应的用户"),
    MERCHANT_NOT_EXIST(50001, "商家不存在"),

    WALLET_BUSY(6001,"钱包服务繁忙"),
    COIN_ADDRESS_ERROR(6002,"地址错误"),
    TRADE_NOT_ALLOW(6003,"禁止内部提币"),
    BALANCE_INSUFFICIENT(6004,"余额不足"),
    WALLET_WITHDRAW_PAUSED(6005,"暂停提币"),
    COIN_PROTOCOL_BLANK(6006,"币种协议为空"),
    COIN_TRADE_24(6008,"交易24小时内不能提币"),
    WITHDRAW_LESS_MIN(6009,"少于最小提币数量"),
    NEED_TO_UPDATE_APP(226,"您的版本已经过期\n请至gbex.com下载最新版"),
    WALLET_DEPOSIT_PAUSED(6007,"暂停充值"),
    WALLET_SIGN_ERROR(225,"签名不正确");

    private final int errorCode;
    private final String errorMsg;


    private ErrorEnum(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }


    public int getErrorCode() {
        return errorCode;
    }


    public String getErrorMsg() {
        return errorMsg;
    }


    @SuppressWarnings("rawtypes")
    public Result getResult() {
        return Result.fail(this.errorCode, this.errorMsg);
    }

    public Result fillAlertView(String msg) {
        return Result.fail(ErrorEnum.CONFIRM_ALERT_INFO.getErrorCode(), MessageFormat.format(ErrorEnum.CONFIRM_ALERT_INFO.getErrorMsg(), msg));
    }

}
